package test4_2.demo01;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Homework19_4 {
    public static void main(String[] args) {
        Set<String> names = new HashSet<>();

        names.add("a");
        names.add("b");
        names.add("c");
        names.add("a");
        names.add("d");

        System.out.println("for-each：");
        for (String name : names) {
            System.out.println(name);
        }

        System.out.println("Iterator：");
        Iterator<String> iterator = names.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
